package common

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

func Ok(c *gin.Context, data interface{}) {
	c.JSON(200, gin.H{"code": 0, "data": data, "msg": "ok"})
}

func Err(c *gin.Context, code int, msg string) {
	c.JSON(200, gin.H{"code": code, "msg": msg})
}

func SerErr(c *gin.Context, code int, msg string) {
	c.JSON(code, gin.H{"msg": msg})
}

//用户未验证错误
func ErrUnauth(c *gin.Context, msg string) {
	SerErr(c, http.StatusUnauthorized, msg)
}

//服务不可用错误
func ErrUnavailable(c *gin.Context, msg string) {
	SerErr(c, http.StatusServiceUnavailable, msg)
}

